﻿using RPAVIEW.util;
using SUNRPA.CONTROLS.IMPL.domain.flowItemParam;
using System.Windows;
using System.Windows.Controls;
using MouseMoveInput = RPAVIEW.views.EditPage.flows.MouseMoveN.Input;

namespace RPAVIEW.views.EditPage.flows.MouseClickN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        private MouseMoveInput mouseMoveInput;
        public Input() {
            InitializeComponent();
            MouseClickNParam param = WindowUtil.GetWindow<FlowEditWindow>().DataContext as MouseClickNParam;
            if(param != null && param.Move == true) {
                //创建移动鼠标视图
                mouseMoveInput = new MouseMoveInput();
                mouseMoveInput.DataContext = param.Mmp;
                this.MoveConfigPanel.Children.Add(mouseMoveInput);
            } else {
                this.MoveConfigPanel.Children.Clear();
            }
        }

        public override void UpdateSource() {
            this.clickTypeBox.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.buttonTypeBox.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.isMove.GetBindingExpression(CheckBox.IsCheckedProperty).UpdateSource();
            if(this.mouseMoveInput != null) { 
                mouseMoveInput.UpdateSource();
            }
        }

        private void ConfigMove(object sender, RoutedEventArgs e) {
            bool? isMove = this.isMove.IsChecked;
            if(isMove == true) {
                //创建移动鼠标视图
                mouseMoveInput = new MouseMoveInput();
                MouseMoveNParam mmp = new MouseMoveNParam();
                mouseMoveInput.DataContext = mmp;
                (WindowUtil.GetWindow<FlowEditWindow>().DataContext as MouseClickNParam).Mmp = mmp;
                this.MoveConfigPanel.Children.Add(mouseMoveInput);
            } else {
                this.MoveConfigPanel.Children.Clear();
            }
        }
    }
}
